/**
 * 订单接口
 */
import {
  HTTP
} from '../utils/http.js';
import utils from '../utils/util';

class orderModel extends HTTP {
  
  // 供应商订单列表查询
  orderListPage(data, sCallback, showLoading) {
    this.request({
      url: 'supplier/app/order/listPage',
      method: 'get',
      data: data,
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    },'',showLoading)
  }

  // 查询订单详情
  orderFindById(data, sCallback) {
    this.request({
      url: 'supplier/app/order/findById',
      method: 'get',
      data: data,
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    })
  }
  
  // 取消订单
  orderCancel(data, sCallback) {
    this.request({
      url: 'supplier/app/order/cancel',
      method: 'post',
      data: data,
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    })
  }
  
  // 接单
  orderAcceptl(data, sCallback) {
    this.request({
      url: 'supplier/app/order/accept',
      method: 'post',
      data: data,
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    },'postJson')
  }
  
  // 发货
  orderSend(data, sCallback, showLoading) {
    this.request({
      url: 'supplier/app/order/send',
      method: 'post',
      data: data,
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    },'',showLoading)
  }
  
  // 改单
  updateOrder(data, sCallback) {
    this.request({
      url: 'supplier/app/order/updateOrder',
      method: 'post',
      data: data,
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    })
  }
  
  // 查询可改单列表
  listUpdateOrderPage(data, sCallback, showLoading) {
    this.request({
      url: 'supplier/app/order/listUpdateOrderPage',
      method: 'get',
      data: data,
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    },'',showLoading)
  }

  // 修改订单
  updateOrderInfo(data, sCallback) {
    this.request({
      url: 'supplier/app/order/updateOrderInfo',
      method: 'post',
      data: data,
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    }, 'postJson')
  }

}
export {
  orderModel
}